notebook: Make dnd safe against tab disappearance
authorMatthias Clasen <mclasen@redhat.com>
Fri, 30 Jan 2015 04:51:26 +0000 (23:51 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 30 Jan 2015 15:13:15 +0000 (10:13 -0500)
when the dragged tab is being removed during the drag operation,
we need to cancel the drag. To do so, we have to keep around
a reference to the drag context.

This should fix
https://bugzilla.gnome.org/show_bug.cgi?id=732051

gtk/gtknotebook.c

index 2bf9e74a65817d9ecd2e73dd37c93cfb9549e3af..aba3daa12346627b91e6b00e1c2b0da61469d8c5 100644 (file)
@@ -3711,6 +3711,7 @@ gtk_notebook_drag_begin (GtkWidget        *widget,
                     G_CALLBACK (on_drag_icon_draw), notebook);
 
   gtk_drag_set_icon_widget (context, priv->dnd_window, -2, -2);
+  g_object_set_data (G_OBJECT (priv->dnd_window), "drag-context", context);
 }
 
 static void
@@ -5052,7 +5053,17 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
     }
 
   if (priv->detached_tab == list->data)
-    priv->detached_tab = NULL;
+    {
+      priv->detached_tab = NULL;
+
+      if (priv->operation == DRAG_OPERATION_DETACH)
+        {
+          GdkDragContext *context;
+
+          context = (GdkDragContext *)g_object_get_data (G_OBJECT (priv->dnd_window), "drag-context");
+          gtk_drag_cancel (context);
+        }
+    }
   if (priv->prelight_tab == list->data)
     update_prelight_tab (notebook, NULL);
   if (priv->switch_tab == list)